export function toType(obj: unknown) {
    if (obj === null) return obj + ''
    const class2type: Map<string, string> = new Map<string, any>(),
        toString = class2type.toString;
    [
        'Number',
        'String',
        'Boolean',
        'Symbol',
        'Function',
        'Array',
        'Object',
        'Date',
        'RegExp',
        'Error'
    ].forEach(name => {
        class2type.set(`[object ${name}]`, name.toLocaleLowerCase())
    })
    // 把前面两个当作一个整体看
    return typeof obj === 'object' || typeof obj === 'function' ?
        class2type.get(toString.call(obj)) || 'object' :
        typeof obj
}